	/*******************************************************************************
*   			Impacts of a Large-Scale Parenting Program: 				   *
*					Experimental Evidence from Chile						   *
********************************************************************************


	REQUIRES:	"${dt_final}panel_RR_indexes.dta"
	CREATES:	${out_tables}/T13A_iv_child_individual.xls
				
	WRITEN BY:  Italo Lopez  [italolop@usc.edu]

********************************************************************************
	Prepare data
*******************************************************************************/

	* Load data
	use "${dt_final}/panel_RR_indexes.dta", clear


	* Establish macros for regressions

/*******************************************************************************
*   Set macros for regressions
*******************************************************************************/
	
	* Outcomes
	*-----------------------------------------------------------
	local childoutcomes  "zDCCSPunt zptevir_irtscore2 zt_score zcbcl_t_e zcbcl_t_i zibatt_sspi zibatt_ssai zibatt_sssr zas_raw_score" 
	local behaviors "home_score se_score disc_score" 
	local beliefs "zpstyle1 zpstyle2 zpstyle3 zPSCS zPSSS_family zPSSS_friends zPSSS_others zPSI_Distress zCESD zpacotis"	
	local child "zptevir_irtscore2 zcog_index zsoc_index" 

	* Controls
	*-----------------------------------------------------------

	macro  def Xvar1 "i.age_year i.gender"  	
	macro  def Xvar2 "i.age_year i.gender inc_qtaut_old i.pc_edu_mdsfin hh_mem hh_tipo"  	
	macro  def Xvar2old "i.gender inc_qtaut_old i.pc_edu_mdsfin_old hh_mem hh_tipo"  

	
	* Parental characteristics: WAIS and BFI and imputed wais 
	*-----------------------------------------------------------

	macro def parent_cha4 "BFI_ext BFI_ope BFI_con BFI_neu BFI_agr wais2 flag_wais"
	
	* Plot settings 
	*--------------------------------- 
	set scheme white_tableau
	graph set window fontface "Times New Roman"
	global graph_pref "graphregion(color(white) margin(vsmall)) "

/*******************************************************************************
	Figure 2: Parental Outcomes at Follow-up by Treatment Arm
*******************************************************************************/



	graph bar (mean) zfbeh_gsem zfbel_gsem zfwb if x==1, /*
	*/ over(TIPO, relabel(1 "Control" 2 "NEP-B" 3 "NEP-I")) /*
	*/ legend(lab(1  "Parenting behavior index") /*
	*/ label(2 "Parenting beliefs index") /* 
	*/ label(3 "Parental well-being index") pos(6)) /*
	*/ bar(1, color(black) lcolor(black)) /* 
	*/ bar(2, color(white) lcolor(black)) /*
	*/ bar(3, color(gs8) lcolor(black)) /*
	*/ ylab(, nogrid)	$graph_pref ytitle("ITT Impacts in SDs")
	gr export "$out_graphs/F2_parentout_followup.eps", replace
	gr export "$out_graphs/F2_parentout_followup.wmf", replace 


	tabstat zfbeh_gsem zfbel_gsem zfwb if x==1, by (TIPO) s(mean N)
	